<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.w3.org/1999/xhtml">
<head>
    <style type="text/css">
        .background{
            background: antiquewhite url("../static/img/bg.png") no-repeat center;
            margin-top: 30px;
        }

    </style>
    <meta charset="UTF-8">
    <title></title>
</head>
<body>
    <form action="/upload/saveFile" method="post" enctype="multipart/form-data" >
        <div class="background">
            <h2>文件上传方法</h2>
            <input type="file"  placeholder="请点击上传文件" name="file">
            <input type="submit"  value="上传" >
        </div>
    </form>
    <iframe name='hidden_frame' id="hidden_frame" style='display: none'></iframe>
    <div class="background">
        <h2>文件下载方法</h2>
        <table>
            <thead>
                <th>序号</th>
                <th>文件名称</th>
                <th>操作</th>
            </thead>
            <tbody>
                <tr th:each="entry,start:${list}">
                    <td th:text="${start.count}"></td>
                    <td th:text="${entry['fileName']}"></td>
                    <td>
                        <a th:href="@{'http://localhost:9999/upload/downloadFile?fileId='+${entry['fileId']}}" target="_blank">下载</a>
                    </td>
                </tr>
            </tbody>
        </table>
    </div>
</body>
<script>
    $('#hidden_frame').load(function(){
        var text = $(this).contains().find("body").text();
        var res = $.parseJSON(text);
        if(res.code =='200'){
            alert('文件上传成功')
            location.reload();
        }else {
            alert('文件上传失败')
        }
    })
</script>
</html>
